cmake_minimum_required(VERSION 3.14)

project(segger_rtt VERSION 1.0.0 LANGUAGES C ASM)

# 包含系统类型公共定义
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../src/os_adapt/cmake/system_types.cmake)

# 根据系统类型选择源文件
if(SYSTEM_TYPE EQUAL SYSTEM_TYPE_RTTHREAD)
    # RT-Thread系统（通常是ARM架构）
    add_library(segger_rtt STATIC
        RTT/SEGGER_RTT.c
        RTT/SEGGER_RTT_printf.c
        RTT/SEGGER_RTT_ASM_ARMv7M.S
    )
else()
    # 非RT-Thread系统（如Linux、FreeRTOS等）
    add_library(segger_rtt STATIC
        RTT/SEGGER_RTT.c
        RTT/SEGGER_RTT_printf.c
    )
endif()

target_include_directories(segger_rtt PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/RTT
    ${CMAKE_CURRENT_SOURCE_DIR}/Config
)

target_compile_options(segger_rtt PRIVATE
    -Wall
    -Wextra
)

set_target_properties(segger_rtt PROPERTIES
    C_STANDARD 11
    C_STANDARD_REQUIRED ON
)